import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * 简易滑动窗口
 */
public class Solution3 {
    public static void main(String[] args) {
        int[] arrays = new int[]{0, 0, 1, 1, 0, 1, 0, 0};
        System.out.println(reverse(0, arrays));
    }

    public static int reverse(int target, int[] arrays) {
        List<Integer> max = new ArrayList<>();
        for (int i = 0; i < arrays.length; i++) {
            int size = 1;
            int left = i - 1;
            int right = i + 1;
            while (left >= 0) {
                if (arrays[left] == target) {
                    size++;
                    left--;
                } else {
                    break;
                }
            }
            while (right < arrays.length) {
                if (arrays[right] == target) {
                    size++;
                    right++;
                } else {
                    break;
                }
            }
            max.add(size);
        }
        return max.stream().max(Comparator.naturalOrder()).get();
    }
}
